package com.ndood.core.proxy;

import java.util.Date;

/**
 * 讯代理 动态IP代理请求头
 * caps.setCapability(PhantomJSDriverService.PHANTOMJS_PAGE_CUSTOMHEADERS_PREFIX+"Proxy-Authorization", authHeader());
 */
public class XDailiAuthHeaderGeneartor {
	public static String authHeader(){
		int timestamp = (int) (new Date().getTime()/1000);
		//拼装签名字符串
        String planText = String.format("orderno=%s,secret=%s,timestamp=%d", "ZF201710258576c1VOaQ", "a8e0831d1220493884544bc4d8c45052", timestamp);
        //计算签名
        String sign = org.apache.commons.codec.digest.DigestUtils.md5Hex(planText).toUpperCase();
        //拼装请求头Proxy-Authorization的值
        String authHeader = String.format("sign=%s&orderno=%s&timestamp=%d", sign, "ZF201710258576c1VOaQ", timestamp);
        return authHeader;
    }
}